﻿/*
 * 文件名称：
 * 程序员：liubo
 * 创建时间：2009/12/1
 * 
 * 功能说明：ColumnHelp 的摘要说明
 * 
 * 修改人员：
 * 
 * 修改日期：
 * 
 * 修改记录：
 */
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
///ColumnHelp 的摘要说明
/// </summary>
public class ColumnHelp
{
	public ColumnHelp()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}


    public static string GetFirstColumnId(int ParentId)
    {

        string sql = string.Format("select ColumnID from Whir_Column where ParentId={0} order by sort asc", ParentId);
                DataTable dt = Whir.SQLServerDAL.DbHelperSQL.Query(sql).Tables[0];
                if (dt != null && dt.Rows.Count > 0)
                {
                    return dt.Rows[0]["ColumnID"].ToString();
                }
       
        return "";
    }

    public static string GetColumnName(string ColumnId)
    {
        if (!string.IsNullOrEmpty(ColumnId))
        {
            if (Whir.Common.WebHelper.Utils.IsInt(ColumnId))
            {
                Whir.BLL.Whir_Column bll = new Whir.BLL.Whir_Column();
                Whir.Model.Whir_Column model = bll.GetModel(int.Parse(ColumnId));

                if (model != null)
                {
                    return model.columnName;
                }
            }
        }
        return "";
    }

    public static DataTable GetListByParentId(int parentID)
    {
        string sqlStr = "select * from Whir_Column where parentID = 6  order by sort asc";
        DataTable dt = Whir.SQLServerDAL.DbHelperSQL.Query(sqlStr).Tables[0];
        return dt;
    }

    public static void getReader(string ColumnId, string Url, ModuleMarkMode moduleMarkMode)
    {
        string GetmoduleMark = "";
        switch (moduleMarkMode)
        {
            case ModuleMarkMode.SinglePage: GetmoduleMark = "SinglePage_v0.0.01"; break;
            case ModuleMarkMode.List: GetmoduleMark = "Content_v0.0.01"; break;
            default: GetmoduleMark = "SinglePage_v0.0.01"; break;
        }

        if (!string.IsNullOrEmpty(ColumnId))
        {
            if (Whir.Common.WebHelper.Utils.IsInt(ColumnId))
            {
                Whir.BLL.Whir_Column bll = new Whir.BLL.Whir_Column();
                Whir.Model.Whir_Column model = bll.GetModel(int.Parse(ColumnId));
                if (model != null)
                {
                    string moduleMark = model.moduleMark;
                    if (moduleMark == GetmoduleMark)
                    {
                        HttpContext.Current.Response.Redirect(Url);
                    }
                }
            }
        }

    }

    public static string GetSinglePageContent(string ColumnId)
    {
        if (!string.IsNullOrEmpty(ColumnId))
        {
            if (Whir.Common.WebHelper.Utils.IsInt(ColumnId))
            {
                string sql = "select Content from Whir_U_SinglePage where TypeId=" + ColumnId;
                DataTable dt = Whir.SQLServerDAL.DbHelperSQL.Query(sql).Tables[0];
                if (dt != null && dt.Rows.Count > 0)
                {
                    return dt.Rows[0]["Content"].ToString();
                }
            }
        }
        return "";
    }

    public enum ModuleMarkMode
    {
        SinglePage,
        List
    }



  

}
